package com.joe.demo.netty;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.CompositeByteBuf;

/**
 * @Description
 * @Author gaojw
 * @Date 2024-08-29
 */
public class TestCompositeByteBuf {

    public static void main(String[] args) {
        final ByteBuf buffer1 = ByteBufAllocator.DEFAULT.buffer();
        buffer1.writeBytes(new byte[]{1,2,3,4,5});

        final ByteBuf buffer2 = ByteBufAllocator.DEFAULT.buffer();
        buffer2.writeBytes(new byte[]{6,7,8,9,10});

        final ByteBuf buffer3 = ByteBufAllocator.DEFAULT.buffer();
        buffer3.writeBytes(buffer1).writeBytes(buffer2);
        System.out.println(buffer3);

        final CompositeByteBuf byteBufs = ByteBufAllocator.DEFAULT.compositeBuffer();
        byteBufs.addComponents(true, buffer1, buffer2);
    }
}
